#####################################################################################
# CMAKE MAIN PROJECT - start
#####################################################################################

project(Alejandria)

set(PROJECT_NAME Alejandria)
set(APPLICATION_NAME Alejandria)
set(APPLICATION_VERSION "0.3")
set(TYPE "")

cmake_minimum_required(VERSION 2.6.0)

# Set more locations to look for header files
	include_directories(${CMAKE_CURRENT_SOURCE_DIR}/build)
	include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
####

# Defines a different path to use when compiling release or debug
if (CMAKE_BUILD_TYPE STREQUAL Release)
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Release)
endif (CMAKE_BUILD_TYPE STREQUAL Release)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Debug)
endif (CMAKE_BUILD_TYPE STREQUAL Debug)
####

# Include sqlite folder to create a shared library
subdirs(
	libs/sqlite3/sqlite-amalgamation-3_6_16
)
####

find_package(Qt4 REQUIRED)
set(QT_USE_QTXML true)
set(QT_USE_QTSQL true)
include(${QT_USE_FILE})

qt4_wrap_ui(${PROJECT_NAME}_UIS
	src/view/mainwindow/mainwindow.ui
	src/view/newbookdialog/newbookdialog.ui
	src/view/aboutdialog/aboutdialog.ui
)

qt4_wrap_cpp(${PROJECT_NAME}_MOCS
	${${PROJECT_NAME}_UIS}
	src/model/library.h
	src/view/mainwindow/mainwindow.h
	src/view/mainwindow/categorydelegate.h
	src/view/mainwindow/subcategorydelegate.h
	src/view/mainwindow/statusdelegate.h
	src/view/mainwindow/owndelegate.h
	src/view/mainwindow/loaneddelegate.h
	src/view/mainwindow/ratingdelegate.h
	src/view/newbookdialog/newbookdialog.h
	src/view/aboutdialog/aboutdialog.h
)

# Defines the type of executable depending on the OS
if (WIN32)
	# If we compile release we need to make sure the
	# console window doesn't show
	if (CMAKE_BUILD_TYPE MATCHES Release)
		set(TYPE WIN32)
		LINK_LIBRARIES(${QT_QTMAIN_LIBRARY})
	endif(CMAKE_BUILD_TYPE MATCHES Release)
endif (WIN32)

if (APPLE)
	set(TYPE MACOSX_BUNDLE)
endif (APPLE)

#TODO: Linux

####

add_executable(${PROJECT_NAME} ${TYPE}
	src/main.cpp
	src/model/library.cpp
	src/view/mainwindow/mainwindow.cpp
	src/view/mainwindow/categorydelegate.cpp
	src/view/mainwindow/subcategorydelegate.cpp	
	src/view/mainwindow/statusdelegate.cpp
	src/view/mainwindow/owndelegate.cpp	
	src/view/mainwindow/loaneddelegate.cpp	
	src/view/mainwindow/ratingdelegate.cpp
	src/view/newbookdialog/newbookdialog.cpp
	src/view/aboutdialog/aboutdialog.cpp
	${${PROJECT_NAME}_MOCS}
)

# Installation and Packaging
include(CMakeLists-install.cmake)
####

target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
#####################################################################################
# CMAKE MAIN PROJECT - end
#####################################################################################